#coding = utf-8

import getpass

def get_passwd():
	try:
		with open('passwd.txt') as f:
			passwd = f.readline().strip()
		return passwd
	except Exception as e:
		raise e
count = 0
while count < 3:
	user_passwd = getpass.getpass('请输入密码：')
	passwd = get_passwd()
	if user_passwd != passwd:
		count += 1
		print("密码错误，请重试！（最多有3次尝试的机会）")
		continue
	print("密码正确")
	break
else:
	print("重试了3次，，，退出。")
